﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using AMM.Business;
using AMM.Business.Config;
using AMM.CustomClassLibrary;
using AMM.Model;

namespace AMM.UserControls {
    public partial class BaseSearchControl : UserControl {

        protected void BindIsEnabled(ListControl control) {
            List<object> resultList = new List<object>();
            resultList.Add(new { Text = "", Value = "-1" });
            resultList.Add(new { Text = "启用", Value = "1" });
            resultList.Add(new { Text = "没有启用", Value = "0" });

            control.DataSource = resultList;
            control.DisplayMember = "Text";
            control.ValueMember = "Value";
        }

        protected void BindAuditStatus(ListControl control) {
            control.DataSource = MethodHelper.GetEnumDescriptionToList(typeof(AuditStatus), true);
            control.DisplayMember = "Text";
            control.ValueMember = "Value";
        }

        protected virtual void BindBasics(ListControl control, BasicsType basicsType) {
            control.DataSource = new BasicsProcessor().FetchEnabledBasicsByType(basicsType);
            control.DisplayMember = "Name";
            control.ValueMember = "BasicsId";
        }

        protected DateTime? GetDateTimePickerValue(DateTimePicker dtp) {
            if (dtp.Checked) {
                return dtp.Value;
            }
            else {
                return null;
            }
        }

        public virtual BaseSearchModel GetSearchModel() {
            return new BaseSearchModel();
        }

        public virtual void ResetSearchModel() {

        }
    }
}
